<%@ include file="db.jsp" %>
<%@ include file="jspmkrfn.jsp" %>
<%@ page session="true" buffer="16kb" import="java.util.*,java.text.*"%>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<% Locale locale = Locale.getDefault();
locale = new Locale("zh","CN"); 
response.setLocale(locale);%>
<%
boolean validpwd = true;
String escapeString = "\\\\'";
if (request.getParameter("submit") != null && request.getParameter("submit").length() > 0) {

	// Setup variables
	String userid = request.getParameter("userid");
	String passwd = request.getParameter("passwd");
	if (("root".toUpperCase().equals(userid.toUpperCase())) && ("123456".toUpperCase().equals(passwd.toUpperCase()))) {
		session.setAttribute("project1_status", "login");

		// Write cookies
		if (request.getParameter("rememberme") != null) {
			Cookie cookie = new Cookie("project1_userid", userid);
			cookie.setMaxAge(365*24*60*60);
			response.addCookie(cookie);
		}
		response.sendRedirect("index.jsp");
	}else{
		validpwd = false;
	}
}
%>
<html>
<head>
	<title>物资管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="project1.css" rel="stylesheet" type="text/css" />
<meta name="generator" content="JSPMaker v1.0.0.0" />
<link href="css/login.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript" src="ew.js"></script>
<script language="JavaScript">
<!-- start JavaScript
function  EW_checkMyForm(EW_this) {
if  (!EW_hasValue(EW_this.userid, "TEXT" )) {
            if  (!EW_onError(EW_this, EW_this.userid, "TEXT", "请输入账号！"))
                return false;
        }
if  (!EW_hasValue(EW_this.passwd, "PASSWORD" )) {
            if  (!EW_onError(EW_this, EW_this.passwd, "PASSWORD", "请输入密码！"))
                return false;
        }
return true;
}

// end JavaScript -->
</script>
<body>

<%
Cookie cookie = null;
Cookie [] ar_cookie = request.getCookies();
String userid = "";
for (int i = 0; i < ar_cookie.length; i++){
	cookie = ar_cookie[i];
	if (cookie.getName().equals("project1_userid")){
		userid = (String) cookie.getValue();
	}
}
%>
<form action="login.jsp" method="post" onSubmit="return EW_checkMyForm(this);">
<div class="bck">
        <div class="login">
		    <img src="img/supplier.jpeg" alt=""/> 
			<p class="header">管理员登陆</p>
			<table border="0" cellspacing="0" cellpadding="4" align="center">
				<tr>
					<td>
				    	<img src="img/id.png" alt=""/>
					</td>
				  	<td>
						<span class="jspmaker">账号:</span>
					</td>
					<td>
						<span class="jspmaker"><input class="field" type="text" name="userid" size="20"></span>
					</td>
				</tr>
				<tr>
					<td>
				    	<img src="img/pwd.png" alt=""/>
					</td>
					<td>
						<span class="jspmaker">密码:</span>
					</td>
					<td>
						<span class="jspmaker"><input class="field" type="password" name="passwd" size="20"></span>
					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td align="right"><span class="jspmaker"><input type="checkbox" name="rememberme" value="true">记住密码</span></td>
				</tr>
			</table>
			<span class="jspmaker"><input id="denglu" type="submit" name="submit" value="登      录"></span>
        </div>
    </div>
</form>
<br>
<% if (!validpwd) { %>
<p class=align="center"><span class="jspmaker" style="color: Red;">输入密码不正确！</span></p>
<% } %>
</body>
</html>
